package com.atguigu.day07;

import com.sun.xml.internal.ws.encoding.MtomCodec;

public class Test06 {
    public static void main(String[] args) {
        MathTools m1 = new MathTools();
        System.out.println(m1.add(2, 2));
        System.out.println(m1.subtract(2, 3));
        System.out.println(m1.mutiply(2, 2));
        System.out.println(m1.divide(5, 2));
        System.out.println(m1.remainder(5, 3));
        System.out.println("max:" + m1.max(3, 5));
        System.out.println("min" + m1.min(3, 5));
        System.out.println("equals:4,5:" + m1.equals(4, 5));
        System.out.println("equals:4,4:" + m1.equals(4, 4));
        System.out.println(m1.isEven(6));
        System.out.println(m1.isPrimeNumer(8));
        System.out.println("round3.14:" + m1.round(3.14));
        System.out.println("round3.54:" + m1.round(3.54));

    }
}

class MathTools {
    int add(int a, int b) {
        return a + b;
    }

    int subtract(int a, int b) {
        return a - b;
    }

    int mutiply(int a, int b) {
        return a * b;
    }

    int divide(int a, int b) {
        return a / b;
    }

    int remainder(int a, int b) {
        return a % b;
    }

    int max(int a, int b) {
        return a > b ? a : b;
    }

    int min(int a, int b) {
        return a < b ? a : b;
    }

    boolean equals(int a, int b) {
        return a == b;
    }

    boolean isEven(int a) {
        return a % 2 == 0;
    }

    boolean isPrimeNumer(int a) {
        boolean isPrime = true;
        for (int i = 2; i <= Math.sqrt(a); i++) {
            if (a % i == 0) {
                isPrime = false;
                break;
            }
        }
        return isPrime;
    }

    int round(double d) {
        double ro = d * 10;
        if (ro % 10 >= 5) {
            return (int) (d + 1);
        } else
            return (int) d;
    }
}
